home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2001 December / pcwk12201b.iso / Wersje pelne i specjalne / Winamp 2.77 i 3.0beta / wasabi-sdk_beta1.exe / studio / common / rootwnd.h < prev    next >
C/C++ Source or Header  |  2001-10-08  |  14KB  |  471 lines

  1. /*
  2.  
  3.   Nullsoft WASABI Source File License
  4.  
  5.   Copyright 1999-2001 Nullsoft, Inc.
  6.  
  7.     This software is provided 'as-is', without any express or implied
  8.     warranty.  In no event will the authors be held liable for any damages
  9.     arising from the use of this software.
  10.  
  11.     Permission is granted to anyone to use this software for any purpose,
  12.     including commercial applications, and to alter it and redistribute it
  13.     freely, subject to the following restrictions:
  14.  
  15.     1. The origin of this software must not be misrepresented; you must not
  16.        claim that you wrote the original software. If you use this software
  17.        in a product, an acknowledgment in the product documentation would be
  18.        appreciated but is not required.
  19.     2. Altered source versions must be plainly marked as such, and must not be
  20.        misrepresented as being the original software.
  21.     3. This notice may not be removed or altered from any source distribution.
  22.  
  23.  
  24.   Brennan Underwood
  25.   brennan@nullsoft.com
  26.  
  27. */
  28.  
  29. #ifndef _ROOTWND_H
  30. #define _ROOTWND_H
  31.  
  32. #include "std.h"
  33.  
  34. #include "dispatch.h"
  35.  
  36. class CanvasBase;
  37. class Region;
  38.  
  39. // only these methods are safe across dll boundaries
  40. // this is the pointer you find in the GWL_USERDATA of a window
  41.  
  42. class DragInterface;
  43.  
  44. enum WndPreferences {
  45.   SUGGESTED_X,
  46.   SUGGESTED_Y,
  47.   SUGGESTED_W,
  48.   SUGGESTED_H,
  49. };
  50.  
  51. class COMEXP NOVTABLE RootWnd : public Dispatchable {
  52. protected:
  53.   RootWnd() {}    // protect constructor
  54. public:
  55. #ifdef WIN32
  56.  
  57.   // this passes thru to the windows WndProc, if there is one -- NONPORTABLE
  58.   virtual LRESULT wndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)=0;
  59.  
  60.   // get the HWND (if there is one) -- NONPORTABLE
  61.   HWND gethWnd();
  62. #endif
  63.  
  64.   int init(RootWnd *parent, int nochild=FALSE);
  65.   int isInited();    // are we post init() ? USE THIS INSTEAD OF gethWnd()==1
  66.  
  67.   // fetch the DragInterface of the RootWnd here, can be NULL
  68.   DragInterface *getDragInterface();
  69.  
  70.   int getCursorType(int x, int y);
  71.  
  72.   // returns deepest child for point or yourself if no child there
  73.   RootWnd *rootWndFromPoint(POINT *pt);
  74.  
  75.   void getClientRect(RECT *);
  76.   void getNonClientRect(RECT *rect);
  77.   // the onscreen coordinates
  78.   void getWindowRect(RECT *r);
  79.  
  80.   void setVisible(int show);
  81.   int isVisible();
  82.   int getSkinId();
  83.  
  84.   int onMetricChange(int metricid, int param1=0, int param2=0);
  85.  
  86.   // painting stuff
  87.   void invalidate();
  88.   void invalidateRect(RECT *r);
  89.   void invalidateRgn(Region *r);
  90.   void invalidateFrom(RootWnd *who);
  91.   void invalidateRectFrom(RECT *r, RootWnd *who);
  92.   void invalidateRgnFrom(Region *r, RootWnd *who);
  93.   void validate();
  94.   void validateRect(RECT *r);
  95.   void validateRgn(Region *reg);
  96.   int onPaint(CanvasBase *canvas, Region *r);
  97.   int paintTree(CanvasBase *canvas, Region *r);
  98.   RootWnd *getParent();
  99.   RootWnd *getRootParent();
  100.   void setParent(RootWnd *newparent);
  101.   int onSiblingInvalidateRgn(Region *r, RootWnd *who, int who_idx, int my_idx);
  102.   int wantSiblingInvalidations();
  103.   int cascadeRepaintFrom(RootWnd *who);
  104.   int cascadeRepaintRgnFrom(Region *reg, RootWnd *who);
  105.   int cascadeRepaintRectFrom(RECT *r, RootWnd *who);
  106.   int cascadeRepaint();
  107.   int cascadeRepaintRgn(Region *reg);
  108.   int cascadeRepaintRect(RECT *r);
  109.   void repaint();
  110.   RootWnd *getBaseTextureWindow();
  111.   int onDeferredCallback(int param1, int param2);
  112.   int childNotify(RootWnd *child, int msg, int p1, int p2);
  113.   int getPreferences(int what);
  114.   virtual void setStartHidden(int sh)=0;
  115.  
  116.   virtual double getRenderRatio()=0;
  117.   virtual void setRenderRatio(double r)=0;
  118.   virtual void resize(int x, int y, int w, int h)=0;
  119.   inline void resizeToRect(RECT *r) {
  120.     resize(r->left, r->top, r->right - r->left, r->bottom - r->top);
  121.   }
  122.   virtual void move(int x, int y)=0;
  123.  
  124.   // virtual child stuff
  125.   virtual void addVirtualChild(RootWnd *child)=0;
  126.   virtual void removeVirtualChild(RootWnd *child)=0;
  127.   virtual int isVirtual()=0;//FUCKO KILLME
  128.   virtual RootWnd *getVirtualChild(int x, int y)=0;
  129.   virtual RootWnd *getVirtualChild(int _enum)=0;
  130.   virtual int getNumVirtuals()=0;
  131.   virtual void bringVirtualToFront(RootWnd *w)=0;
  132.   virtual void bringVirtualToBack(RootWnd *w)=0;
  133.   virtual void bringVirtualAbove(RootWnd *w, RootWnd *b)=0;
  134.   virtual void bringVirtualBelow(RootWnd *w, RootWnd *b)=0;
  135.  
  136.   virtual int beginCapture();
  137.   virtual int endCapture();
  138.   virtual int getCapture();    // returns 1 if this window has mouse/keyb captured
  139.   virtual void setVirtualChildCapture(RootWnd *child)=0;
  140.   virtual RootWnd *getVirtualChildCapture()=0;
  141.   virtual int setVirtualChildTimer(RootWnd *child, int id, int ms)=0;
  142.   virtual int killVirtualChildTimer(RootWnd *child, int id)=0;
  143.   virtual void timerCallback(int id)=0;
  144.  
  145.   virtual BOOL mouseInRegion(int x, int y)=0;
  146.   virtual int checkDoubleClick(int button, int x, int y)=0;
  147.   virtual int onLeftButtonDblClk(int x, int y)=0;
  148.   virtual int onRightButtonDblClk(int x, int y)=0;
  149.   virtual int onLeftButtonUp(int x, int y)=0;
  150.   virtual int onRightButtonUp(int x, int y)=0;
  151.   virtual int onLeftButtonDown(int x, int y)=0;
  152.   virtual int onRightButtonDown(int x, int y)=0;
  153.   virtual int onMouseMove(int x, int y)=0;
  154.   virtual int isClickThrough();
  155.  
  156.   virtual void clientToScreen(int *x, int *y); // so rootWndFromPoint can map ratio
  157.   virtual void screenToClient(int *x, int *y); // ..        
  158.  
  159.   virtual int onActivate();
  160.   virtual int onDeactivate();
  161.  
  162.   enum {
  163.     GETHWND        = 100,
  164.     GETDRAGINTERFACE    = 200,
  165.     FROMPOINT        = 300,
  166.     GETWINDOWRECT    = 400,
  167.     ISVISIBLE        = 500,
  168.     GETSKINID        = 600,
  169.     ONMETRICCHANGE    = 700,
  170.     ONPAINT        = 800,
  171.     PAINTTREE = 900,
  172.     GETPARENT = 1000,
  173.     GETROOTPARENT = 1001,
  174.     SETPARENT = 1002,
  175.     ONDEFERREDCALLBACK = 1100,
  176.     CHILDNOTIFY = 1200,
  177.     GETPREFERENCES = 1300,
  178.     BEGINCAPTURE = 1400,
  179.     ENDCAPTURE = 1401,
  180.     GETCAPTURE = 1402,
  181.     CLICKTHROUGH = 1500,
  182.     CLIENTSCREEN = 1600,
  183.     SCREENCLIENT = 1601,
  184.     INIT = 1700,
  185.     GETCURSORTYPE = 1800,
  186.     GETCLIENTRECT = 1900,
  187.     GETNONCLIENTRECT = 1901,
  188.     SETVISIBLE = 2000,
  189.     INVALIDATE = 2100,
  190.     INVALIDATERECT = 2101,
  191.     INVALIDATERGN = 2102,
  192.     INVALIDATEFROM = 2103,
  193.     INVALIDATERECTFROM = 2104,
  194.     INVALIDATERGNFROM = 2105,
  195.     VALIDATE = 2200,
  196.     VALIDATERECT = 2201,
  197.     VALIDATERGN = 2202,
  198.     ONSIBINVALIDATE = 2300,
  199.     WANTSIBINVALIDATE = 2301,
  200.     CASCADEREPAINTFROM = 2400,
  201.     CASCADEREPAINTRECTFROM = 2401,
  202.     CASCADEREPAINTRGNFROM = 2402,
  203.     CASCADEREPAINT = 2403, 
  204.     CASCADEREPAINTRECT = 2405,
  205.     CASCADEREPAINTRGN = 2406,
  206.     REPAINT = 2500,
  207.     GETTEXTUREWND = 2600,
  208.     ONACTIVATE = 2700,
  209.     ONDEACTIVATE = 2800,
  210.   };
  211. };
  212.  
  213. // inline helper functions definitions
  214. #ifdef WIN32
  215. inline HWND RootWnd::gethWnd() {
  216.   return _call(GETHWND, (HWND)NULL);
  217. }
  218. #endif
  219. inline DragInterface *RootWnd::getDragInterface() {
  220.   return _call(GETDRAGINTERFACE, (DragInterface*)0);
  221. }
  222.  
  223. inline RootWnd *RootWnd::rootWndFromPoint(POINT *pt) {
  224.   return _call(FROMPOINT, (RootWnd*)0, pt);
  225. }
  226.  
  227. inline void RootWnd::getWindowRect(RECT *r) {
  228.   if (!_voidcall(GETWINDOWRECT, r)) Std::setRect(r, 0, 0, 0, 0);
  229. }
  230.  
  231. inline int RootWnd::isVisible() {
  232.   return _call(ISVISIBLE, 0);
  233. }
  234.  
  235. inline int RootWnd::getSkinId() {
  236.   return _call(GETSKINID, 0);
  237. }
  238.  
  239. inline int RootWnd::onMetricChange(int metricid, int param1, int param2) {
  240.   return _call(ONMETRICCHANGE, 0, metricid, param1, param2);
  241. }
  242.  
  243. inline int RootWnd::onPaint(CanvasBase *canvas, Region *r) {
  244.   return _call(ONPAINT, 0, canvas, r);
  245. }
  246.  
  247. inline int RootWnd::paintTree(CanvasBase *canvas, Region *r) {
  248.   return _call(PAINTTREE, 0, canvas, r);
  249. }
  250.  
  251. inline RootWnd *RootWnd::getParent() {
  252.   return _call(GETPARENT, (RootWnd *)0);
  253. }
  254.  
  255. inline RootWnd *RootWnd::getRootParent() {
  256.   return _call(GETROOTPARENT, (RootWnd *)0);
  257. }
  258.  
  259. inline void RootWnd::setParent(RootWnd *parent) {
  260.   _voidcall(SETPARENT, parent);
  261. }
  262.  
  263. inline int RootWnd::onDeferredCallback(int param1, int param2) {
  264.   return _call(ONDEFERREDCALLBACK, 0, param1, param2);
  265. }
  266.  
  267. inline int RootWnd::childNotify(RootWnd *child, int msg, int p1, int p2) {
  268.   return _call(CHILDNOTIFY, 0, child, msg, p1, p2);
  269. }
  270.  
  271. inline int RootWnd::getPreferences(int what) {
  272.   return _call(GETPREFERENCES, 0, what);
  273. }
  274.  
  275. inline int RootWnd::beginCapture() {
  276.   return _call(BEGINCAPTURE, 0);
  277. }
  278.  
  279. inline int RootWnd::endCapture() {
  280.   return _call(ENDCAPTURE, 0);
  281. }
  282.  
  283. inline int RootWnd::getCapture() {
  284.   return _call(GETCAPTURE, 0);
  285. }
  286.  
  287. inline int RootWnd::isClickThrough() {
  288.   return _call(CLICKTHROUGH, 0);
  289. }
  290.  
  291. inline void RootWnd::clientToScreen(int *x, int *y) {
  292.   _voidcall(CLIENTSCREEN, x, y);
  293. }
  294.  
  295. inline void RootWnd::screenToClient(int *x, int *y) {
  296.   _voidcall(SCREENCLIENT, x, y);
  297. }
  298.  
  299. inline int RootWnd::init(RootWnd *parent, int nochild) {
  300.   return _call(INIT, 0, parent, nochild);
  301. }
  302.  
  303. inline int RootWnd::getCursorType(int x, int y) {
  304.   return _call(GETCURSORTYPE, 0, x, y);
  305. }
  306.  
  307. inline  void RootWnd::getClientRect(RECT *r) {
  308.   _voidcall(GETCLIENTRECT, r);
  309. }
  310.  
  311. inline void RootWnd::getNonClientRect(RECT *rect) {
  312.   _voidcall(GETNONCLIENTRECT, rect);
  313. }
  314.  
  315. inline void RootWnd::setVisible(int show) {
  316.   _voidcall(SETVISIBLE, show);
  317. }
  318.  
  319. inline void RootWnd::invalidate() {
  320.   _voidcall(INVALIDATE);
  321. }
  322.   
  323. inline void RootWnd::invalidateRect(RECT *r) {
  324.   _voidcall(INVALIDATERECT, r);
  325. }
  326.  
  327. inline void RootWnd::invalidateRgn(Region *r) {
  328.   _voidcall(INVALIDATERGN, r);
  329. }
  330.  
  331. inline void RootWnd::invalidateFrom(RootWnd *who) {
  332.   _voidcall(INVALIDATEFROM, who);
  333. }
  334.  
  335. inline void RootWnd::invalidateRectFrom(RECT *r, RootWnd *who) {
  336.   _voidcall(INVALIDATERECTFROM, r, who);
  337. }
  338.  
  339. inline void RootWnd::invalidateRgnFrom(Region *r, RootWnd *who) {
  340.   _voidcall(INVALIDATERGNFROM, r, who);
  341. }
  342.  
  343. inline void RootWnd::validate() {
  344.   _voidcall(VALIDATE);
  345. }
  346.  
  347. inline void RootWnd::validateRect(RECT *r) {
  348.   _voidcall(VALIDATERECT, r);
  349. }
  350.  
  351. inline void RootWnd::validateRgn(Region *reg) {
  352.   _voidcall(VALIDATERGN, reg);
  353. }
  354.  
  355. inline int RootWnd::onSiblingInvalidateRgn(Region *r, RootWnd *who, int who_idx, int my_idx) {
  356.   return _call(ONSIBINVALIDATE, 0, r, who, who_idx, my_idx);
  357. }
  358.  
  359. inline int RootWnd::wantSiblingInvalidations() {
  360.   return _call(WANTSIBINVALIDATE, 0);
  361. }
  362.  
  363. inline int RootWnd::cascadeRepaintFrom(RootWnd *who) {
  364.   return _call(CASCADEREPAINTFROM, 0, who);
  365. }
  366.  
  367. inline int RootWnd::cascadeRepaintRgnFrom(Region *reg, RootWnd *who) {
  368.   return _call(CASCADEREPAINTRGNFROM, 0, reg, who);
  369. }
  370.  
  371. inline int RootWnd::cascadeRepaintRectFrom(RECT *r, RootWnd *who) {
  372.   return _call(CASCADEREPAINTRECTFROM, 0, r, who);
  373. }
  374.  
  375. inline int RootWnd::cascadeRepaint() {
  376.   return _call(CASCADEREPAINT, 0);
  377. }
  378.  
  379. inline int RootWnd::cascadeRepaintRgn(Region *reg) {
  380.   return _call(CASCADEREPAINTRGN, 0, reg);
  381. }
  382.  
  383. inline int RootWnd::cascadeRepaintRect(RECT *r) {
  384.   return _call(CASCADEREPAINTRECT, 0, r);
  385. }
  386.  
  387. inline void RootWnd::repaint() {
  388.   _voidcall(REPAINT);
  389. }
  390.  
  391. inline RootWnd *RootWnd::getBaseTextureWindow() {
  392.   return _call(GETTEXTUREWND, (RootWnd *)0);
  393. }
  394.  
  395. inline int RootWnd::onActivate() {
  396.   return _call(ONACTIVATE, 0);
  397. }
  398.   
  399. inline int RootWnd::onDeactivate() {
  400.   return _call(ONDEACTIVATE, 0);
  401. }
  402.  
  403. class COMEXP NOVTABLE RootWndI : public RootWnd {
  404. protected:
  405.   RootWndI() {}    // protect constructor
  406.  
  407. public:
  408. #ifdef WIN32
  409.   virtual HWND gethWnd()=0;
  410. #endif
  411.   virtual DragInterface *getDragInterface()=0;
  412.   virtual RootWnd *rootWndFromPoint(POINT *pt)=0;
  413.  
  414.   virtual void getWindowRect(RECT *r)=0;
  415.   virtual int isVisible()=0;
  416.   virtual int getSkinId()=0;
  417.   virtual int onMetricChange(int metricid, int param1, int param2)=0;
  418.   virtual int onDeferredCallback(int param1, int param2)=0;
  419.   virtual int childNotify(RootWnd *child, int msg, int p1, int p2)=0;
  420.   virtual int getPreferences(int what)=0;
  421.  
  422.   virtual int rootwnd_paintTree(CanvasBase *canvas, Region *r)=0;
  423.   virtual RootWnd *getParent()=0;
  424.   virtual RootWnd *getRootParent()=0;
  425.   virtual void setParent(RootWnd *parent)=0;
  426.  
  427.   virtual int beginCapture()=0;
  428.   virtual int endCapture()=0;
  429.   virtual int getCapture()=0;
  430.  
  431.   virtual int rootwnd_onPaint(CanvasBase *canvas, Region *r)=0;
  432.   virtual int isClickThrough()=0;
  433.  
  434.   virtual void clientToScreen(int *x, int *y)=0; 
  435.   virtual void screenToClient(int *x, int *y)=0; 
  436.  
  437.   virtual int init(RootWnd *parent, int nochild)=0;
  438.   virtual int getCursorType(int x, int y)=0;
  439.   virtual void getClientRect(RECT *r)=0;
  440.   virtual void getNonClientRect(RECT *rect)=0;
  441.   virtual void setVisible(int show)=0;
  442.   virtual void invalidate()=0;
  443.   virtual void invalidateRect(RECT *r)=0;
  444.   virtual void invalidateRgn(Region *r)=0;
  445.   virtual void invalidateFrom(RootWnd *who)=0;
  446.   virtual void invalidateRectFrom(RECT *r, RootWnd *who)=0;
  447.   virtual void invalidateRgnFrom(Region *r, RootWnd *who)=0;
  448.   virtual void validate()=0;
  449.   virtual void validateRect(RECT *r)=0;
  450.   virtual void validateRgn(Region *reg)=0;
  451.  
  452.   virtual int onSiblingInvalidateRgn(Region *r, RootWnd *who, int who_idx, int my_idx)=0;
  453.   virtual int wantSiblingInvalidations()=0;
  454.   virtual int cascadeRepaintFrom(RootWnd *who)=0;
  455.   virtual int cascadeRepaintRgnFrom(Region *reg, RootWnd *who)=0;
  456.   virtual int cascadeRepaintRectFrom(RECT *r, RootWnd *who)=0;
  457.   virtual int cascadeRepaint()=0;
  458.   virtual int cascadeRepaintRgn(Region *reg)=0;
  459.   virtual int cascadeRepaintRect(RECT *r)=0;
  460.   virtual void repaint()=0;
  461.   virtual RootWnd *getBaseTextureWindow()=0;
  462.   
  463.   virtual int onActivate()=0;
  464.   virtual int onDeactivate()=0;
  465.  
  466. protected:
  467.   RECVS_DISPATCH;
  468. };
  469.  
  470. #endif
  471.